package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.bean.RoleBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IRoleMapper extends BaseMapper<RoleBean> {
    @Select("SELECT * FROM t_role;")
    @ResultMap("roleMap")
    List<RoleBean> findAll();

    @Delete("delete from t_role_grade where fk_roleId=#{roleId};" +
            "DELETE FROM t_user_role WHERE fk_roleId=#{roleId};"+
            "delete from t_role where pk_roleId=#{roleId}")
    void delRole(Integer roleId);

    @Delete("delete from t_role_grade where fk_roleId=#{roleId};")
    void delRoleGrade(Integer roleId);

    List<RoleBean> findByUserId(Integer userId);
}
